﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YoloImageDetect
{
    public class ProfilesHelper
    {
        /// <summary>
        /// 从 YAML 文件加载类别名称
        /// </summary>
        public static Dictionary<int, string> LoadClassNamesFromYaml(string yamlFilePath)
        {
            var classNames = new Dictionary<int, string>();
            using (var reader = new System.IO.StreamReader(yamlFilePath))
            {
                var yaml = new YamlDotNet.RepresentationModel.YamlStream();
                yaml.Load(reader);
                var mapping = (YamlDotNet.RepresentationModel.YamlMappingNode)yaml.Documents[0].RootNode;

                foreach (var entry in mapping.Children)
                {
                    int classId = Convert.ToInt32(entry.Key.ToString());
                    string className = entry.Value.ToString();
                    classNames[classId] = className; // 添加类别名称
                }
            }
            return classNames;
        }
    }
}
